﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ExportData.CApSceneDataExporter
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Windows.Forms;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.ExportData;

public class CApSceneDataExporter
{
  private CApSceneDataExporterViewModel m_viewModel;

  public CApSceneDataExporter(CApSceneDataExporterViewModel apVM) => this.m_viewModel = apVM;

  public bool Launch(out List<string> idList)
  {
    Cursor current = Cursor.Current;
    Cursor.Current = Cursors.WaitCursor;
    idList = new List<string>();
    TxObjectList allItems = TxApplication.ActiveSelection.GetAllItems();
    TxApplication.ActiveSelection.Clear();
    try
    {
      TxExportGraphicsAnimationInitData animationInitData = new TxExportGraphicsAnimationInitData(this.m_viewModel.Root == null ? (ITxObject) TxApplication.ActiveDocument.PhysicalRoot : this.m_viewModel.Root, this.m_viewModel.SceneDataFileFullPath, this.m_viewModel.SimulationFileFullPath, this.m_viewModel.CompressExportData, this.m_viewModel.SelectedLOD, this.m_viewModel.ExportSimulation);
      animationInitData.ExportData = this.m_viewModel.ExportInfo;
      animationInitData.FileFormat = this.m_viewModel.ExportFileFormat;
      animationInitData.UseVerticesAbsoluteLocation = this.m_viewModel.UseVerticesAbsoluteLocation;
      TxExportGraphicsAnimationEx.Init(animationInitData);
      foreach (DictionaryEntry animationObjectName in TxExportGraphicsAnimationEx.GetAnimationObjectNames())
        idList.Add((animationObjectName.Key as ITxObject).Id);
      animationInitData.Dispose();
    }
    catch (Exception ex)
    {
      return false;
    }
    TxApplication.ActiveSelection.SetItems(allItems);
    Cursor.Current = current;
    return true;
  }
}
